{% if targetType == 'classroom'%}
  {% set maxRate = classroom.maxRate %}
{% elseif targetType == 'course' %}
  {% set maxRate = course.maxRate %}
{% else %}
  {% set maxRate = level.maxRate %}
{% endif %}


<div class="order-item clearfix">
<div class='order-item-title' width='50px'>
<i class="es-icon es-icon-money"></i>
<span class="title">学习卡</span>
<span >
      （提交订单之后学习卡状态将改变）</span>
</div>
  
<div style="float:left;" class="" >
        <select name="card" id='card'  style="width:200px;" onChange="GaiBian(this)"  >
           <option value="0" data-m="0" >请选择</option>
           {% for cards in cards %}
           <option value="{{ cards.id }}" data-m="{{ cards.money }}" data-category="{{ cards.category }}">{% if cards.category==0 %}【通用】{% elseif cards.category==3 %}【课程】{% elseif cards.category==6 %}【题库】{% elseif cards.category==1 %}【班级】{% endif %}{{ cards.title }}(剩余金额{{ cards.money }}元)</option>
           {% endfor %}
         </select>
 </div> 
  <div class="order-item-price" style="width:25%">
    <span class="mrs">本订单最高可抵扣</span>
    {# {% if priceType|default("RMB") == "RMB" %}<span>￥</span>{% endif %}
    <span role="cash-discount" style="font-size: 24px"></span>
    <span>
      {% if priceType|default("RMB") == "RMB" %} {% else %} {{ setting("coin.coin_name") }} {% endif %}
    </span>
    {% if priceType|default("RMB") == "RMB" %}
      
    {% endif %}  #}
<span>￥</span>
 <span id="discard" style="font-size: 24px">0.00</span>
  </div>
</div> 
<div class="order-item clearfix">
  <div class="order-item-title" style="width:30%">
    <i class="es-icon es-icon-money"></i>
    <span class="title">{{ setting("coin.coin_name") }}</span>
    <span>（1元 = {{cashRate}}{{setting("coin.coin_name")}}）</span>
  </div>
  <div class="order-item-detail">
    {% if hasPayPassword %}
    本次使用
    <input  {% if maxRate == 0 and priceType|default("RMB") == "RMB" %}readonly="true"{% endif %} id="coinPayAmount" class="form-control text-center inline-block width-input-small mhm" role="coinNum" type="text" name="coinPayAmount" value="0" maxlength="">
    {{setting("coin.coin_name")}}
    {% endif %}
    <span class="coin-detail hidden-xs hidden-sm">
      （账户余额：<span class="text-danger" role="accountCash">{{account.cash|default(0)}}</span> {{setting("coin.coin_name")}}）
    </span>
     
    <input style="display:none">{# Prevent autocompleting #}
    <input type="password" style="display:none">{# Prevent autocompleting #}
    {% if not hasPayPassword %}
    <div  class="alert alert-warning alert-xs mtm inline-block" style="line-height:20px">
        为了保障账户资金安全，请先
      <a class="alert-link" href="javascript:;" data-toggle="modal" data-target="#modal" data-url="{{path('settings_set_pay_password')}}">设置支付密码</a>
    </div>
    {% else %}
    
    <div role="password-input" style="display:none">
        
      <div class="controls mtm">
       
        <input id="payPassword" class="form-control width-input-large inline-block" name="payPassword" type="password" placeholder="请输入支付密码" data-url="{{path('pay_password_check')}}" autocomplete="off"/>
        <a href="{{path('settings_find_pay_password')}}" target='_blank' class="btn-link">忘记密码？</a>
        <br>
         
      </div>
        
    </div>
      
    {% endif %}
  </div>
    
  <div class="order-item-price" style="width:25%">
    <span class="mrs">抵扣</span>
     {% if priceType|default("RMB") == "RMB" %}<span>￥</span>{% endif %}
    <span role="cash-discount" style="font-size: 24px"></span>
    <span>
      {% if priceType|default("RMB") == "RMB" %} {% else %} {{ setting("coin.coin_name") }} {% endif %}
    </span>
    {% if priceType|default("RMB") == "RMB" %}
      <p style="font-size:13px;" class="hidden-xs hidden-sm">(本订单最高可以使用<span id= "maxCoin" role="maxCoin">{{maxCoin|default(0)}}</span>{{setting("coin.coin_name")}})</p>
    {% endif %}
  </div>
</div>
<script>
	function GaiBian(obj){
		$('[role="no-use-coupon-code"]').text("（没有使用优惠码）");
		var mz=$('#mz').val();
		if(Number(mz)>0){
			$('[role="coupon-code"]').css('display','none');
			$('[role="code-notify"]').css('display','none');
			$("#coupon-code-btn").css('display','inline-block');
			$('[role="price"]').text("0.00");
			$("#promo").val("");
			$("#mz").val("");
		}
		
		
		//得到选中的金额
		var money = Number($("#card option:selected").attr("data-m"));
		var category = $("#card option:selected").attr("data-category");
		//酷币
		var coin=Number($('[role="cash-discount"]').text());
		var yfjg=Number($('[role="total-price"]').text());
		var cm			= '0';
		if(category == '0' || category == '6')
			cm = yfjg*1 > money ? money : yfjg*1;
		else
			cm = yfjg > money ? money : yfjg;
		$('#cm').val(cm);
		$('#discard').text(cm);
		
		
		
		var rmb = Number($('[role="pay-rmb"]').text());
		
		if(cm >= yfjg)
		{
			
			$('[role="cash-discount"]').text(0);
			$('[role="coinNum"]').val(0);
			$("#discard").text(yfjg);
			$("#cm").val(yfjg);
			$('[role="password-input"]').css('display','none');
			$('[role="pay-rmb"]').text('0.00');
			$('#shouldPayMoney').val('0.00');
		}
		else if(cm + coin >= yfjg)
		{
			
			$('[role="cash-discount"]').text(yfjg - cm);
			$('[role="pay-rmb"]').text('0.00');
			$('[role="coinNum"]').val((yfjg-cm)*10);
			$('#shouldPayMoney').val('0.00');
			
		}
		else if(cm + coin < yfjg)
		{
			var coin=Number($('[role="cash-discount"]').text());
			var num=yfjg - cm - coin;
			var num=num.toFixed(2);
			$('[role="pay-rmb"]').text(num);
			$('#shouldPayMoney').val(num);
		}
		//本订单最高可以使用的酷币数
		$('[role="maxCoin"]').text(((yfjg-cm)*10).toFixed(2));
	}


</script>